package com.jk.service.account;

import com.jk.dao.account.AccThemeDao;
import com.jk.entity.account.AccTheme;
import com.jk.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;

/**
 * ACC_THEME service
 * Tue Sep 22 11:02:19 CST 2015 yanghuan
 */
@Service
public class AccThemeService {

    @Autowired
    private AccThemeDao accThemeDao;
    private static final String ACC_THEME_ID = "1b417b85-02f2-423b-b8df-678f7059b1f8";

    public int save(AccTheme accTheme) throws DataAccessException {
        if (StringUtil.isEmpty(accTheme.getAccThemeId())) {
            accTheme.setAccThemeId(ACC_THEME_ID);
            return accThemeDao.insert(accTheme);
        } else {
            return accThemeDao.updateByPrimaryKeySelective(accTheme);
        }
    }

    public AccTheme select() throws DataAccessException {
        AccTheme accTheme = accThemeDao.selectByPrimaryKey(ACC_THEME_ID);
        if (null == accTheme) {
            accTheme = new AccTheme();
        }
        return accTheme;
    }

}

